﻿using System;
using Microsoft.SmallBasic.Library;
using SmallBasicFun;

namespace SpiderWeb
{
    public class SpiderWeb
    {
        private static int LinesOfShape = 40;
        static decimal zoom = 1;
        static decimal length = 1;
        public static void Main()
        {
            //Make the tortoise go as fast as possible
            Tortoise.Show();
            Tortoise.SetSpeed(10);
            //Change the width of the line the tortoise draws to 1 pixel
            Tortoise.SetPenWidth(1);
            //Change the color of the line the tortoise draws to silver
            Tortoise.SetPenColor(Colors.HotPink);
            //The current length of a line is 10 pixels
            length = 5;
            //The current zoom is 1
            zoom = 1;
            //Do the following 10 times
            for (int i = 0; i < 15; i++)
            {
                // WeaveOneLayer (recipe below)
                WeaveOneLayer();
                // Change the zoom so it is multiplied by 1.3
                zoom = zoom * (decimal) 1.3;
                //Repeat
            }

        }


        public static void WeaveOneLayer()
        {            //------------- Recipe for WeaveOneLayer

            //Do the following 6 times
            for (int i = 0; i < 6; i++)
            {
                // DrawTriangle (recipe below)
                DrawTriangle();
                // Turn the tortoise 1/6th of 360 degrees to the right
                Tortoise.Turn(360 / 6);
                // Increase the length of the line by the current zoom
                length = length + zoom;
                
                DrawTriangle();
                // Turn the tortoise 1/6th of 360 degrees to the right
                Tortoise.Turn(360 / 6);
                // Increase the length of the line by the current zoom
                length = length + zoom;
                //Repeat

                //------------- End of WeaveOneLayer recipe
            }
        }
        public static void DrawTriangle()
        {
            //------------- Recipe for DrawTriangle
            
            //Do the following 3 times
            for (int i = 0; i < LinesOfShape; i++)
            { // Move the tortoise the length of a line
                Tortoise.Move(length);
                // Turn the tortoise 1/3rd of 360 degrees
                Tortoise.Turn(360 / LinesOfShape);
                //Repeat
                Tortoise.Move(length);
                // Turn the tortoise 1/3rd of 360 degrees
                Tortoise.Turn(360 / LinesOfShape);
                //------------- End of DrawTriangle recipe

            }

        }

    }
}